<!--tvm票款差异协查-->
<template>
  <div class="TvmJiezhangdanjuxiecha el-card is-always-shadow el-card__body">
    <el-dialog
      title="操作回馈信息"
      :visible.sync="dialogVisible"
      @close="closed"
      width="950px">
      <avue-form v-if="isReload" class="TvmJiezhangdanjuxiechaForm" :option="option" v-model="formData" @submit="handleSubmit">
        <template slot-scope="scope" slot="rReceiveMoney">
          {{formData.rReceiveMoney=formData.rReceiveNotes+formData.rReceiveCoin+".00"}}
          <el-input v-model="formData.rReceiveMoney" disabled></el-input>
        </template>
        <template slot-scope="scope" slot="rChangeTotalMoney">
          {{formData.rChangeTotalMoney=formData.rNoteChange+formData.rCoinChange+".00"}}
          <el-input v-model="formData.rChangeTotalMoney" disabled></el-input>
        </template>
        <template slot-scope="scope" slot="menuForm">
          <el-button type="primary" @click="closed">返回</el-button>
        </template>
      </avue-form>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";

  import {
    electromeReasons,
    fenExYuangettoFixed,
    getMappingStatusArray,
    qianxiangType,
    fenExYuangettoFixed2
  } from "../../../../../../../api/subwayRat/commonCheck";
  import {
    editor_xw_SwAuTvmDailyBillAssistDetail,
    get_xw_SwAuTvmDailyBillAssistDetail
  } from "../../../../../../../api/stationTiecketManager/shuJuXieChaGuanLi/TVM/XT/TVMRJZDJ/JDZYDLCK";

  export default {
    components:{
    },
    data() {
      return {
        masterId:'',//主表Id
        isReload:true,
        //1编辑，2添加
        showType:1,

        dialogVisible:true,
        formData:{
        },
        id:0,
        option:{

        }
    }
    },
    created() {
    },
    methods: {
      fenExYuangettoFixed2,
      handleSubmit(form,done){
        let param={};
        Object.assign(param,this.formData);
        this.fenZhuanYuan(param,false);
        // param.id = this.id;
        editor_xw_SwAuTvmDailyBillAssistDetail(param).then(res=>{
          if(res.data.code==0){
            this.$message.success("操作成功！");
            this.closed();
            this.$parent.getList();
            this.$parent.cancelChoose();
          }else{
            this.$message.error(res.data.msg);
          }
        }).catch(e=>{
          this.$message.error("操作失败！");
        });
        done();
      },
      recallShow(row,showType){
        this.showType=showType;
        this.getOption();
        this.formData={};
        Object.assign(this.formData,row);
        this.id = row.id;
        debugger
        get_xw_SwAuTvmDailyBillAssistDetail({relationid:row.id}).then((res)=>{
          debugger
          if(res.data.code!=0){
              this.$message.error("获取数据失败！");
              return;
          }
          let r=this.fenZhuanYuan(res.data.data[0],true);
          r.cid = r.id;
          delete r.id;
          r.crid = r.relationid;
          delete r.relationid;
          Object.assign(this.formData,r); //
        }).catch((e)=>{
          this.$message.error("获取数据失败！");
        })
      },
      fenZhuanYuan(row,isYuan){
        if(!row)
            return;
        if(isYuan){
          row.rReceiveNotes=fenExYuangettoFixed(row,'rReceiveNotes');
          row.rReceiveCoin=fenExYuangettoFixed(row,'rReceiveCoin');
          row.rReceiveMoney=fenExYuangettoFixed(row,'rReceiveMoney');
          row.rNoteChange=fenExYuangettoFixed(row,'rNoteChange');
          row.rCoinChange=fenExYuangettoFixed(row,'rCoinChange');
          row.rChangeTotalMoney=fenExYuangettoFixed(row,'rChangeTotalMoney');
          row.rSellTicketMoney=fenExYuangettoFixed(row,'rSellTicketMoney');
          row.rRechargeTotal=fenExYuangettoFixed(row,'rRechargeTotal');
          row.rReturnTotal=fenExYuangettoFixed(row,'rReturnTotal');
          row.eSellTicketMoney=fenExYuangettoFixed(row,'eSellTicketMoney');
          row.eRechargeTotal=fenExYuangettoFixed(row,'eRechargeTotal');
          row.eReturnTotal=fenExYuangettoFixed(row,'eReturnTotal');
        }else{
          row.rReceiveNotes=Number(row.rReceiveNotes)*100;
          row.rReceiveCoin=Number(row.rReceiveCoin)*100;
          row.rReceiveMoney=Number(row.rReceiveMoney)*100;
          row.rNoteChange=Number(row.rNoteChange)*100;
          row.rCoinChange=Number(row.rCoinChange)*100;
          row.rChangeTotalMoney=Number(row.rChangeTotalMoney)*100;
          row.rSellTicketMoney=Number(row.rSellTicketMoney)*100;
          row.rRechargeTotal=Number(row.rRechargeTotal)*100;
          row.rReturnTotal=Number(row.rReturnTotal)*100;
          row.eSellTicketMoney=Number(row.eSellTicketMoney)*100;
          row.eRechargeTotal=Number(row.eRechargeTotal)*100;
          row.eReturnTotal=Number(row.eReturnTotal)*100;
        }

        return row;
      },
      closed(){
        this.dialogVisible=false;
        this.$parent.isShowDia=false;
      },
      getOption(){
        this.option={
          submitBtn:this.showType==1,
          emptyBtn:false,
          submitText:'确认',
          span:12,
          group:[
            {
              icon:'',
              label: '',
              // collapse:false,
              prop: 'group1',
              column: [{
                label: 'TVM编号',
                prop: 'tvmCode',
                type: 'input',
                width:250,
                labelWidth:110,
                disabled: true,},
                {
                label: '开始时间',
                prop: 'incomeSettleBeginTime',
                type: 'datetime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd HH:mm:ss',
                width:250,
                labelWidth:110,
                disabled: this.showType==2
              },{
                label: '结束时间',
                prop: 'incomeSettleEndTime',
                type: 'datetime',
                format: 'yyyy-MM-dd',
                valueFormat: 'yyyy-MM-dd HH:mm:ss',
                width:'250',
                labelWidth:110,
                disabled: this.showType==2
              }]
            },
            {
              icon:'',
              label: '现金支付',
              // collapse:false,
              prop: 'group2',
              column:[{
                label: '接收纸币',
                prop: 'rReceiveNotes',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==2
              }, {
                label: '接收硬币',
                prop: 'rReceiveCoin',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==2
              },
                {
                  label: '接收统计',
                  prop: 'rReceiveMoney',
                  type: 'number',
                  formslot:true,
                  labelWidth:110,
                  precision:2,
                  disabled: true
                },
                {
                  label: '纸币找零',
                  prop: 'rNoteChange',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                }, {
                  label: '硬币找零',
                  prop: 'rCoinChange',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                },
                {
                  label: '找零统计',
                  prop: 'rChangeTotalMoney',
                  type: 'number',
                  formslot:true,
                  labelWidth:110,
                  precision:2,
                  disabled: true
                },{
                  label: '售票金额',
                  prop: 'rSellTicketMoney',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                }, {
                  label: '充值金额',
                  prop: 'rRechargeTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                },
                {
                  label: '退款金额',
                  prop: 'rReturnTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                }]
            },
            {
              icon:'',
              label: '电子支付',
              // collapse:false,
              prop: 'group3',
              column:[{
                label: '售票金额',
                prop: 'eSellTicketMoney',
                type: 'number',
                labelWidth:110,
                precision:2,
                disabled: this.showType==2
              },
                {
                  label: '充值金额',
                  prop: 'eRechargeTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                },
                {
                  label: '退款金额',
                  prop: 'eReturnTotal',
                  type: 'number',
                  labelWidth:110,
                  precision:2,
                  disabled: this.showType==2
                }
              ]
            },
            {
              icon:'',
              label: '原因备注',
              // collapse:false,
              prop: 'group4',
              column:[{
                label: '归属机电专业回馈原因',
                prop: 'electromeReason',
                type: 'select',
                labelWidth:180,
                span: 8,
                dicData:getMappingStatusArray('electrome_reasons'),
                disabled: this.showType==2
              },
                {
                  label: '备注',
                  prop: 'remark',
                  type: 'textarea',
                  labelWidth:110,
                  disabled: this.showType==2
                }
              ]
            }

          ]
        } ;
        this.isReload=false;
        this.$nextTick(()=>{
          this.isReload=true;
        })
      }
    },
    mounted() {

    }
  }
</script>
<style lang="scss">
  .TvmJiezhangdanjuxiecha{
    .TvmJiezhangdanjuxiechaForm{
      .el-form-item{
        min-width: 150px;
      }
      .avue-form__row{
        width: 30%;
      }
      .avue-group[index='4']{
        .el-form-item{
          min-width: 450px;
        }
        .avue-form__row{
          width: 70%;
        }
      }
    }
  }

</style>
